package welsch.androidwerwolf.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import welsch.androidwerwolf.Globals;
import welsch.androidwerwolf.Player;
import welsch.androidwerwolf.R;
import welsch.androidwerwolf.Role.Role;


public class MainActivity extends ActionBarActivity {

    private Button cBtnPlayerSetting = null;
    private Button cBtnPlay = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        cBtnPlayerSetting = (Button) findViewById(R.id.cBtnPlayerSettingsMainActivity);
        initPlayerSettingButton();
        initPlayButton();
        //create dummyData
        Globals.gPlayerList.add(new Player("Mausi1"));
        Globals.gPlayerList.add(new Player("Mausi2"));
        Globals.gPlayerList.add(new Player("Mausi3"));
        Globals.gPlayerList.add(new Player("Mausi4"));
        Globals.gPlayerList.add(new Player("Mausi5"));
        Globals.gPlayerList.add(new Player("Mausi6"));
        Globals.gPlayerList.add(new Player("Mausi7"));
        Globals.gPlayerList.add(new Player("Mausi8"));
        Globals.gPlayerList.add(new Player("Mausi9"));
        Globals.gPlayerList.add(new Player("Mausi10"));
        Globals.gPlayerList.add(new Player("Mausi11"));
        Globals.gPlayerList.add(new Player("Mausi12"));

        Globals.gRoleList.add(new Role("Werwolf",""));
        Globals.gRoleList.add(new Role("Hexe",""));
        Globals.gRoleList.add(new Role("Dorfbewohner",""));

    }

    private void initPlayerSettingButton(){

        cBtnPlayerSetting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), PlayerSettings.class);
                startActivity(intent);
            }
        });
    }

    private  void initPlayButton(){

        cBtnPlay =(Button) findViewById(R.id.cBtnPlayMainActivity);
        cBtnPlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), GameActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
